﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta name="keywords" content="@Html.Raw(@ViewBag.keywords)">
    <meta name="description" content="@Html.Raw(@ViewBag.description)">
    <link rel="stylesheet" href="~/css/bootstrap.table.min.css" />
    <link rel="stylesheet" href="~/lib/adminlte/css/AdminLTE.icon.font.min.css" />

    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <!-- Bootstrap 3.3.7 -->
    <link href="~/css/bootstrap.min.css" rel="stylesheet" />

    <!-- Font Awesome -->
    <link href="~/css/font-awesome.min.css" rel="stylesheet" />

    <!-- Ionicons -->
    <link href="~/css/ionicons.min.css" rel="stylesheet" />

    <!-- Theme style -->
    <link href="~/lib/adminlte/css/AdminLTE.min.css" rel="stylesheet" />

    <!-- iCheck -->
    <link href="~/lib/iCheck/square/blue.css" rel="stylesheet" />
    <title>开源免费WMS仓库管理系统,苏州 张家港 ERP WMS MES 制造业软件开发</title>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition login-page">

    <div id="app">
        <div class="login-box">

            <div class="login-logo">
                <a href="http://www.kopsoft.cn/" target="_blank"><b>KopSoft</b>仓库管理系统</a>
            </div>

            <!-- /.login-logo -->
            <div class="login-box-body">
                <p class="login-box-msg">Sign in to start your session</p>
                <form onsubmit="return false" method="post">
                    <div class="form-group has-feedback">
                        <input type="text" v-model="UserNickname" id="test" autofocus class="form-control" placeholder="用户名">
                        <span class="fa fa-user form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="password" v-model="Pwd" class="form-control" placeholder="密码" autocomplete="off">
                        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    </div>

                    <div class="row">
                        <div class="col-xs-8">
                            <div class="checkbox icheck">
                                <label>
                                    <input type="checkbox"> Remember Me
                                </label>
                            </div>
                        </div>
                        <!-- /.col -->
                        <div class="col-xs-4">
                            <button type="submit" :disabled="disabled" class="btn btn-primary btn-block btn-flat" v-bind:class="{ 'btn-grey': isSelected}" v-on:click="checkLogin">{{submit}}</button>
                        </div>
                        <!-- /.col -->
                    </div>
                </form>
                <div class="social-auth-links text-center">
                    <p>- OR -</p>
                    <a href="#" class="btn btn-block btn-social btn-facebook btn-flat">
                        <i class="fa fa-facebook"></i> Sign in using
                        Facebook
                    </a>
                    <a href="#" class="btn btn-block btn-social btn-google btn-flat">
                        <i class="fa fa-google-plus"></i> Sign in using
                        Google+
                    </a>
                </div>
                <!-- /.social-auth-links -->
                <strong>&copy;2020<a href="http://www.kopsoft.cn/" target="_blank"> @ViewBag.company</a></strong> 技术支持:15262337653
            </div>
            <!-- /.login-box-body -->
        </div>
    </div>

    <div id="tree" style="margin-top:10px;"></div>

    <script src="~/lib/jquery/3.0/jquery.min.js"></script>
    @*<script src="~/js/snow.min.js"></script>*@
    <script src="~/lib/layer/layer.js"></script>
    <script src="~/js/vqypa.min.js"></script>
    <script src="~/js/bootstrap.min.js"></script>

    @*<script src="~/js/icheck.min.js"></script>*@
    @*<script src="~/lib/iCheck/icheck.js"></script>*@

   @* <script>
        $(function () {
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' /* optional */
            });
        });
    </script>
*@
    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?d0af754958bdae003f041a294eece270";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>

    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                UserNickname: '',
                Pwd: '',
                disabled: false,
                submit: "登录",
                reset: "取消",
                isSelected: false
            },
            methods: {
                checkLogin: function () {
                    var _self = this;
                    _self.disabled = true;
                    _self.isSelected = true;
                    //es5写法
                    if (_self.UserNickname.length <= 0) {
                        layer.msg('用户名不能为空', { icon: 5 });
                        _self.disabled = false;
                        _self.isSelected = false;
                        return false;
                    }
                    if (_self.Pwd.length <= 0) {
                        layer.msg('密码不能为空', { icon: 5 });
                        _self.disabled = false;
                        _self.isSelected = false;
                        return false;
                    }
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });

                    //n = {
                    //    "sys": {
                    //        UserNickname: _self.UserNickname,
                    //        Pwd: _self.Pwd
                    //    }
                    //};

                    yui.$axiospost('/Login/CheckLoginAsync', {
                        UserNickname: _self.UserNickname,
                        Pwd: _self.Pwd
                    })
                        .then(function (response) {
                            _self.disabled = false;
                            _self.isSelected = false;
                            if (response.data.Item1) {
                                _self.submit = "Please Wait...";
                                location.href = "/Home";
                            } else {
                                layer.close(index);
                                layer.msg(response.data.Item2 || errorMsg, { icon: 5 });
                            }
                        })
                        .catch(function (error) {
                            _self.disabled = false;
                            _self.isSelected = false;
                            layer.close(index);
                        });
                },
                cancel: function () {
                    var _self = this;
                    _self.Pwd = _self.UserNickname = "";
                }
            },
            mounted() {
                setTimeout(function () {
                    yui.getDomById("test").focus();
                }, 500);
                //_self.$nextTick(function () {
                //    yui.getDomById("test").focus();
                //});
                //    if (typeof (EventSource) !== 'undefined') {
                //        var eventSource = new EventSource(`http://${location.host}/Home/ServerSendMsg`);
                //        eventSource.onopen = function () {
                //            //console.log('连接打开。。。');
                //        }
                //        eventSource.onerror = function (e) {
                //            //console.log(e);
                //        }
                //        eventSource.onmessage = function (event) {
                //            console.log(event.data);
                //            var origin = event.origin
                //            var last = event.lastEventId
                //        }
                //        //eventSource.addEventListener('message', function (event) {
                //        //    var origin = event.origin;
                //        //    var lastEventId = event.lastEventId;
                //        //    console.log(event.data, 2);
                //        //}, false);
                //    } else {
                //        console.info('浏览器不支持EventSource')
                //    }
            }
        });
    </script>
</body>
</html>